package com.example.studyapplication;

import android.content.Context;
import android.text.TextUtils;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

import com.google.gson.Gson;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.ArrayList;
import java.util.List;


import static org.junit.Assert.assertEquals;

/**
 * Instrumented test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
    @Test
    public void useAppContext() {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
        assertEquals("com.example.studyapplication", appContext.getPackageName());
    }

    @Test
    public void addNullList() {
        List<String> stringList = new ArrayList<>();
        List<String> stringList2 = null;
        stringList.addAll(stringList2);
//        java.lang.NullPointerException:
//        Attempt to invoke interface method 'java.lang.Object[] java.util.Collection.toArray()' on a null object reference
    }

    @Test
    public void floatDelete() {
        float a = 0.14469972f;
        float b =  0.1442209f;
        System.out.println(a-b);
    }


    @Test
    public void listToString() {
        List<String> stringList = new ArrayList<>();
//        stringList.add("ghj");
//        stringList.add("love");
//        stringList.add("wfh");

//        System.out.println(stringList.toString());
        String cacheString = new Gson().toJson(stringList);
        System.out.println("111---"+cacheString);
    }


    @Test
    public void equalsTest() {
        String a = null;
        String b = null;
        System.out.println("---:");
    }

}